<template>
  <div class="my-box">
    <div class="my-top">
      <div class="user-box">
        <div class="user-img">
          <img :src="userInfo.avatar" />
        </div>
        <div class="user-data">
          <div class="user-name">{{ userInfo.nickname }}</div>
          <div class="user-id">ID:{{ userInfo.uid }}</div>
        </div>
        <div class="user-out" @click="loginOut"  style="color:white; font-siez:12px">退出登录</div>
      </div>
    </div>
    <!-- 我的余额 -->
    <div class="my-content">
      <div class="my-money-box">
        <div class="my-yue-box">
          <div class="my-yue" style="color: #999; font-size: 13px">
            我的余额
          </div>
          <div class="my-yue-money">{{userInfo.now_money}}</div>
        </div>
        <div class="my-yongjin-box">
          <div class="my-yongjin" style="color: #999; font-size: 13px">
            当前佣金
          </div>
          <div class="my-yongjin-money">0.00</div>
        </div>
        <div class="my-youhui-box">
          <div class="my-youhui" style="color: #999; font-size: 13px">
            优惠券
          </div>
          <div class="my-youhui-money">0</div>
        </div>
      </div>
    </div>
    <!-- 我的订单 -->
    <div class="my-order-box">
      <div class="my-order">
        <div style="font-size:12px">我的订单</div>
        <div style="margin-left:auto; font-size:12px">全部订单</div>
      </div>
      <div class="my-order-content">
        <van-grid column-num="5">
          <van-grid-item  @click='fahuo0' icon="pending-payment" text="待付款" />
          <van-grid-item  @click='fahuo1' icon="completed" text="待发货" />
          <van-grid-item  @click='fahuo2' icon="logistics" text="待收货" />
          <van-grid-item  @click='fahuo3' icon="chat-o" text="待评价" />
          <van-grid-item  @click='shouhou' icon="refund-o" text="售后/退款" />
        </van-grid>
      </div>
    </div>
    <!-- 我的服务 -->
      <div class="my-order-box">
      <div class="my-order">
        <div style="font-size:12px">我的服务</div>
      </div>
      <div class="my-order-content">
        <van-grid column-num="4" color="red">
          <van-grid-item icon="manager-o" text="会员中心"  />
          <van-grid-item icon="bag-o" text="砍价记录" />
          <van-grid-item icon="logistics" text="我的推广" />
          <van-grid-item icon="friends-o" text="我的余额" />
          <van-grid-item icon="wap-home-o" text="地址/信息" />
          <van-grid-item icon="goods-collect-o" text="我的收藏" />
          <van-grid-item icon="cash-back-record" text="优惠券" />
          <van-grid-item icon="service-o" text="联系客服" />
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapMutations } from "vuex";
export default {
  data() {
    return {
      userInfo: [],
    };
  },
  created() {
    // this.axios.get('api/order/list?page=1&limit=20&type=0').then(res=>{
    //     console.log(res);
    // })
    this.userInfo = JSON.parse(localStorage.userInfo);
    console.log(this.userInfo);
  },
  computed: {
    ...mapGetters(["userInfo"]),
  },
  methods: {
   fahuo0(){
      this.$router.push({
        path:'/fahuo',
        query:{
          title:0
        }
      })
    },
    fahuo1(){
      this.$router.push({
        path:'/fahuo',
        query:{
          title:1
        }
      })
    },
    fahuo2(){
      this.$router.push({
        path:'/fahuo',
        query:{
          title:2
        }
      })
    },
    fahuo3(){
      this.$router.push({
        path:'/fahuo',
        query:{
          title:3
        }
      })
    },
    shouhou(){
      this.$router.push('./shouhou')
    },
    ...mapMutations({
      loginOutByToken: "loginOut",
    }),
    loginOut() {
      this.loginOutByToken();
      this.$router.push("/login");
    },
  },
};
</script>

<style lang="less" scoped>
.my-box {
    height: 800px;
  background-color: rgb(245, 245, 245);
}
.my-top {
  padding: 20px;
  background-color: rgb(233, 51, 35);
  border-radius: 0px 0px 10px 10px;
  height: 15vh;
  .user-box {
    display: flex;
    align-items: center;
    .user-img {
      width: 60px;
      height: 60px;
      border-radius: 30px;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
        display: block;
      }
    }
    .user-data {
      margin-left: 20px;
      .user-name {
        color: white;
        font-size: 20px;
      }
      .user-id {
              color: white;

        font-size: 20px;
      }
    }
    .user-out {
      margin-left: auto;
    }
  }
}

.my-content {
  width: 90%;
  margin: 0 auto;
  margin-top: -30px;
  background-color: #fff;
  margin-top: -40px;
  border-radius: 10px;
  padding: 10px;
  // padding: 20px;
  .my-money-box {
    display: flex;
    text-align: center;

    .my-yue-box {
      flex: 1;
    }
    .my-yongjin-box {
      margin: 0 auto;
      flex: 1;
    }
    .my-youhui-box {
      margin-left: auto;
      flex: 1;
    }
  }
}
.my-order-box{
    width: 94%;
  margin: 0 auto;
  padding: 10px;
    
    .my-order{
        display: flex;
        padding: 10px;
        background-color: #fff;
    }
}
</style>